﻿
using Dapper;
using HBase;
using System;
using System.Data;
namespace hCommand 
{
    //一个任务完成则不允许执行删除任务
    public class LocAreaChangeEngine : GkTransaction {

        public int locId;
        public long areaId;
        public int activeStatus;
        //入库完成反馈
        protected override TransRes Execute()
        {
            CoreWhLoc loc = getById<CoreWhLoc>(locId);
            int moveGroup = loc.moveGroup;
            long oldAreaId = loc.areaId;
            string sql = "update Core_Wh_Loc set area_Id= @areaId,  Active_Status = @activeStatus where id=@locId ";
            if (activeStatus == -1)
            {
                sql = "update Core_Wh_Loc set area_Id= @areaId   where id=@locId ";
            }

            exec(sql, new { locId, areaId, activeStatus });

            if (areaId != oldAreaId)
            {//换库区了
                TransUtil. updateMoveGroup(this, oldAreaId, moveGroup, loc.craneId);
            }
            TransUtil. updateMoveGroup(this, areaId, moveGroup, loc.craneId);
            return new TransRes();
        }




    }
}
